package com.hk.service.impl;

import com.hk.dao.AdminDao;
import com.hk.entity.Admin;
import com.hk.service.AdminService;
import com.hk.service.TeacherService;
import org.mybatis.spring.SqlSessionTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    /**
     * 创建日志记录器（Logger）
     */
    private static final Logger logger = LoggerFactory.getLogger(TeacherService.class);
    @Autowired
    private AdminDao adminDao;

    @Override
    public List<Admin> queryAll() {
        return adminDao.queryAll();
    }

    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;
    @Override
    public void addAdmin(Admin admin) {

        logger.info("生成的 SQL 语句: {}", sqlSessionTemplate.getConfiguration().getMappedStatement("com.hk.dao.AdminDao.addAdmin").getBoundSql(null).getSql());
        adminDao.addAdmin(admin);
    }

    @Override
    public void deleteAdmin(List<Integer> ids) {
        logger.info("删除管理员的 ID 列表: {}", ids);
//        logger.info("生成的 SQL 语句: {}", sqlSessionTemplate.getConfiguration().getMappedStatement("com.hk.dao.AdminDao.deleteAdmin").getBoundSql(ids).getSql());
        adminDao.deleteAdmin(ids);
    }

    @Override
    public Admin getById(Integer id) {
        return adminDao.getById(id);
    }

    @Override
    public void updataAdmin(Admin admin) {
        adminDao.updataAdmin(admin);
    }

    @Override
    public Admin login(Admin admin) {
        return adminDao.getbyuseridANDpassword(admin);
    }

    @Override
    public void uploadUrl(String url, String adminId) {
        adminDao.uploadURL(url,adminId);
    }

    @Override
    public Admin HomeInfo(String adminId) {
        return adminDao.HomeInfo(adminId);
    }


}
